05. Filtering with PCL
Header Text
Filtering with PCL
ND313 C1 L4 A07 Filtering With PCL
The first thing you might notice when looking at the previous loaded point cloud is it’s quite high resolution and spans a pretty far distance. You want your processor pipeline to be able to digest point cloud as quickly as possible, so you will want to filter the cloud down. Here are the two methods that will be used to do this.
Voxel Grid
Voxel grid filtering will create a cubic grid and will filter the cloud by only leaving a single point per voxel cube, so the larger the cube length the lower the resolution of the point cloud.
ND313 Michael Intv 22 What Is A Voxel
Region of Interest
A boxed region is defined and any points outside that box are removed.
To apply these methods you will fill in the point process function
FilterCloud
. The arguments to this function will be your input cloud, voxel grid size, and min/max points representing your region of interest. The function will return the downsampled cloud with only points that were inside the region specified. To get started check out the documentation from PCL for
voxel grid filtering
and
region of interest
.
ND313 C1 L4 A08 Filtering With PCL Pt 2
Results
To apply the filtering function, back in
cityBlock
call the pointProcessor
FilterCloud
function with the loaded pcd.
// Experiment with the ? values and find what works best
filterCloud = pointProcessorI->FilterCloud(inputCloud, ? , Eigen::Vector4f (?, ?, ?, 1), Eigen::Vector4f ( ?, ?, ?, 1));
renderPointCloud(viewer,filterCloud,"filterCloud");
In the filter cloud image below you can now see that the point resolution is much lower than the original, and it cropped everything inside the box points that were specified. It’s important to experiment and play around with the filter input hyper parameters. voxel size should be large enough to help speed up the processing but not so large that object definition is completely lost. For picking a good region, try having a good amount of space in front of the car so it could react quickly in time to any obstacles moving towards it. Also for the sides try to cover at least the width of the road. What’s most important is obstacles that we want to detect are inside the region. Also setting camera angles in
environment.cpp
can help pick a good region of interests. This way you can easily set the camera to have a top down overview or a side overview. One last thing is it would be beneficial to remove points that are hitting the roof of the ego car. You can use a pcl CropBox to find the roof point indices and then feed those indices to a pcl ExtractIndices object to remove them (similar to what your segmentation algorithm used to extract points). The
renderBox
function can be really helpful as well for figuring out how big boxes will look in the scene.
Filtered PCD
Instructions
-
Fill in the
FilterCloud
function inpointProcessor
-
Call
FilterCloud
fromcityBlock
and experiment with hyperparameters - (Optional) Remove ego car roof points
- Observe the results
Workspace
This section contains either a workspace (it can be a Jupyter Notebook workspace or an online code editor work space, etc.) and it cannot be automatically downloaded to be generated here. Please access the classroom with your account and manually download the workspace to your local machine. Note that for some courses, Udacity upload the workspace files onto https://github.com/udacity , so you may be able to download them there.
Workspace Information:
- Default file path:
- Workspace type: react
- Opened files (when workspace is loaded): n/a
ND313 C01 L01 Filtering Using PCL